﻿using Himp.Platform.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;

namespace Himp.Platform.Permissions;

public class PlatformPermissionDefinitionProvider : PermissionDefinitionProvider
{
    public override void Define(IPermissionDefinitionContext context)
    {
        //系统设置
        var settingSysGroupName = context.AddGroup(PlatformPermissions.SettingSysGroupName, L(PlatformPermissions.SettingSysGroupName));
        var organPermission = settingSysGroupName.AddPermission(PlatformPermissions.SettingSys.Organ, L(PlatformPermissions.SettingSys.Organ));
        organPermission.AddChild(PlatformPermissions.SettingSys.OrganCreate, L(PlatformPermissions.SettingSys.OrganCreate));
        organPermission.AddChild(PlatformPermissions.SettingSys.OrganEdit, L(PlatformPermissions.SettingSys.OrganEdit));

        var menuPermission = settingSysGroupName.AddPermission(PlatformPermissions.SettingSys.Menu, L(PlatformPermissions.SettingSys.Menu));
        var rolePermissionPermission = settingSysGroupName.AddPermission(PlatformPermissions.SettingSys.RolePermission, L(PlatformPermissions.SettingSys.RolePermission));

        var staffPermission = settingSysGroupName.AddPermission(PlatformPermissions.SettingSys.Staff, L(PlatformPermissions.SettingSys.Staff));
        staffPermission.AddChild(PlatformPermissions.SettingSys.StaffCreate, L(PlatformPermissions.SettingSys.StaffCreate));
        staffPermission.AddChild(PlatformPermissions.SettingSys.StaffEdit, L(PlatformPermissions.SettingSys.StaffEdit));
        staffPermission.AddChild(PlatformPermissions.SettingSys.StaffDelete, L(PlatformPermissions.SettingSys.StaffDelete));

        var posPermission = settingSysGroupName.AddPermission(PlatformPermissions.SettingSys.Pos, L(PlatformPermissions.SettingSys.Pos));
        posPermission.AddChild(PlatformPermissions.SettingSys.PosCreate, L(PlatformPermissions.SettingSys.PosCreate));
        posPermission.AddChild(PlatformPermissions.SettingSys.PosEdit, L(PlatformPermissions.SettingSys.PosEdit));
        posPermission.AddChild(PlatformPermissions.SettingSys.PosDelete, L(PlatformPermissions.SettingSys.PosDelete));

        var deptmentPermission = settingSysGroupName.AddPermission(PlatformPermissions.SettingSys.Dept, L(PlatformPermissions.SettingSys.Dept));
        deptmentPermission.AddChild(PlatformPermissions.SettingSys.DeptCreate, L(PlatformPermissions.SettingSys.DeptCreate));
        deptmentPermission.AddChild(PlatformPermissions.SettingSys.DeptEdit, L(PlatformPermissions.SettingSys.DeptEdit));
        deptmentPermission.AddChild(PlatformPermissions.SettingSys.DeptDelete, L(PlatformPermissions.SettingSys.DeptDelete));

        var auditlogPermission = settingSysGroupName.AddPermission(PlatformPermissions.SettingSys.Auditlog, L(PlatformPermissions.SettingSys.Auditlog));
        var syslogPermission = settingSysGroupName.AddPermission(PlatformPermissions.SettingSys.Syslog, L(PlatformPermissions.SettingSys.Syslog));
        var msgRecPermission = settingSysGroupName.AddPermission(PlatformPermissions.SettingSys.MsgRec, L(PlatformPermissions.SettingSys.MsgRec));
        var msgTypePermission = settingSysGroupName.AddPermission(PlatformPermissions.SettingSys.MsgType, L(PlatformPermissions.SettingSys.MsgType));
        var noDictPermission = settingSysGroupName.AddPermission(PlatformPermissions.SettingSys.NoDict, L(PlatformPermissions.SettingSys.NoDict));

        //标准字典
        var settingDicGroupName = context.AddGroup(PlatformPermissions.SettingDictGroupName, L(PlatformPermissions.SettingDictGroupName));
        //分类字典
        var catgeDictionaryPermission = settingDicGroupName.AddPermission(PlatformPermissions.SettingSys.CatgeDict, L(PlatformPermissions.SettingSys.CatgeDict));
        //数据字典
        var dataDictionaryPermission = settingDicGroupName.AddPermission(PlatformPermissions.SettingSys.DataDictionary, L(PlatformPermissions.SettingSys.DataDictionary));
        dataDictionaryPermission.AddChild(PlatformPermissions.SettingSys.DataDictionaryCreate, L(PlatformPermissions.SettingSys.DataDictionaryCreate));
        dataDictionaryPermission.AddChild(PlatformPermissions.SettingSys.DataDictionaryEdit, L(PlatformPermissions.SettingSys.DataDictionaryEdit));

        //标准单词
        var stdWordDictPermission = settingDicGroupName.AddPermission(PlatformPermissions.SettingDict.StdWordDict, L(PlatformPermissions.SettingDict.StdWordDict));
        //标准域
        var stdDomainDictPermission = settingDicGroupName.AddPermission(PlatformPermissions.SettingDict.StdDomainDict, L(PlatformPermissions.SettingDict.StdDomainDict));
        var stdPhrDictPermission = settingDicGroupName.AddPermission(PlatformPermissions.SettingDict.StdPhrDict, L(PlatformPermissions.SettingDict.StdPhrDict));
        var stdModelDictPermission = settingDicGroupName.AddPermission(PlatformPermissions.SettingDict.StdModelDict, L(PlatformPermissions.SettingDict.StdModelDict));

        //low-code
        var lowCodgBaseSettingGroupName = context.AddGroup(PlatformPermissions.LowCodgBaseSettingGroupName, L(PlatformPermissions.LowCodgBaseSettingGroupName));
        var projectConfigPermission = lowCodgBaseSettingGroupName.AddPermission(PlatformPermissions.LowCodgBaseSetting.ProjectConfig, L(PlatformPermissions.LowCodgBaseSetting.ProjectConfig));
        var projectSchemaConfigPermission = lowCodgBaseSettingGroupName.AddPermission(PlatformPermissions.LowCodgBaseSetting.ProjectSchemaConfig, L(PlatformPermissions.LowCodgBaseSetting.ProjectSchemaConfig));
        var dataTableConfigPermission = lowCodgBaseSettingGroupName.AddPermission(PlatformPermissions.LowCodgBaseSetting.DataTableConfig, L(PlatformPermissions.LowCodgBaseSetting.DataTableConfig));
        var openApiConfigPermission = lowCodgBaseSettingGroupName.AddPermission(PlatformPermissions.LowCodgBaseSetting.OpenApiConfig, L(PlatformPermissions.LowCodgBaseSetting.OpenApiConfig));
        var dataFormConfigPermission = lowCodgBaseSettingGroupName.AddPermission(PlatformPermissions.LowCodgBaseSetting.DataFormConfig, L(PlatformPermissions.LowCodgBaseSetting.DataFormConfig));

        var workflowManageGroupName = context.AddGroup(PlatformPermissions.WorkflowManageGroupName, L(PlatformPermissions.WorkflowManageGroupName));
        var ProcessDefinition = workflowManageGroupName.AddPermission(PlatformPermissions.WorkflowManage.ProcessDefinition, L(PlatformPermissions.WorkflowManage.ProcessDefinition));
        var ProcessInstance = workflowManageGroupName.AddPermission(PlatformPermissions.WorkflowManage.ProcessInstance, L(PlatformPermissions.WorkflowManage.ProcessInstance));
        var Node = workflowManageGroupName.AddPermission(PlatformPermissions.WorkflowManage.Node, L(PlatformPermissions.WorkflowManage.Node));
        var ProcessType = workflowManageGroupName.AddPermission(PlatformPermissions.WorkflowManage.ProcessType, L(PlatformPermissions.WorkflowManage.ProcessType));
        var workflowManageTodo = workflowManageGroupName.AddPermission(PlatformPermissions.WorkflowManage.Todo, L(PlatformPermissions.WorkflowManage.Todo));
    }

    private static LocalizableString L(string name)
    {
        return LocalizableString.Create<PlatformResource>(name);
    }
}
